home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 September / Chip_2000-09_cd1.bin / sharewar / Slunec / app / 16 / MOD.SWG / 0051_ALM Aley's Module.pas < prev    next >
Pascal/Delphi Source File  |  1997-05-08  |  6KB  |  128 lines

  1.                       ***********************************
  2.                      *** ALM file format DOCUMENTATION ***
  3.                       ***********************************
  4.  
  5. ALM (Aley's Module) is the only MOD-like music format used on 8bit computers.
  6. It is designed to be usable on Sam Coupe (CPU Z80 6MHz) and PC XT. That
  7. computers nomally couldn't play MOD-like music. The ALM file format is very
  8. simple and it have no special effects, so every computer can play the ALMs.
  9.  
  10. ALM file format and ALM Player routine was developed by Aley Keprt some years
  11. ago. Now there is a complete documentation of that music format. (The
  12. documentation was released never before!) The whole player routine is speed
  13. optimized and is about 600 bytes long. The size optimized one is only 300
  14. bytes long. So, this is really the shortest MOD-like music player. :-)
  15.  
  16. There are three versions of ALM. Version 1.1 have speed-info (like S3M),
  17. version 1.0 uses only standart speed. Version 1.2 is the same as 1.1, but it
  18. uses samples-with-header (see below).
  19.  
  20. offset length descrioption
  21. ===================================================
  22.    0      8   id-text "Aley Mod" - version 1.0
  23.    0      7   id-text "AleyMod" - version 1.1 & 1.2 (there is no space!)
  24.    7      1   speed in 1/100 sec. - version 1.1 & 1.2
  25.  
  26. To determine, which format version is that file, read byte 4. If there is char
  27. " " (32dec), it is version 1.0. If there is char "M" (77dec), it is version
  28. 1.1 or 1.2. If the version is 1.0, the speed is always 12. If the version is
  29. 1.1 or 1.2, you should read the version from byte 7. (Read below about the
  30. speed calcs.) Version 1.2 is full-compatible with version 1.1.
  31.  
  32. After this strange intro, both format versions are the same...
  33.  
  34. offset length descrioption
  35. ===================================================
  36.    8      1   length of song (number of positions)
  37.    9      1   restart position
  38.   10    128   order list (sequences 0-127)
  39.  
  40. And that's all. Really short file header, isn't it? After these 138 bytes,
  41. there are patterns. Patterns are stored like STM (or MOD), but there isn't
  42. effect! So, each <note> is only 2 bytes long.
  43.  
  44. first byte = note
  45. second byte = sample
  46.  
  47. ad note: number 0 means "no note"
  48.          numbers  1-12 are octave 1 (1=c, 2=c#, 3=d, etc.)
  49.          numbers 13-24 are octave 2 (13=c, 14=c#, 15=d, etc.)
  50.          numbers 25-36 are octave 3
  51.          number 37 means "key off" (turns the channel off until next note)
  52.  
  53. Order of notes in the pattern:
  54.  ofs.0   row 0, chan 1, note
  55.  ofs.1   row 0, chan 1, sample
  56.  ofs.2   row 0, chan 2, note
  57.  ofs.3   row 0, chan 2, sample
  58.   ...
  59.  ofs.511 row 63,chan 4, sample
  60.  
  61. As you can see, ALM has ALWAYS 4 channels and 64 rows in the pattern. You
  62. can also see that patterns are stored like MOD or STM. The size of one pattern
  63. is always 512 bytes. The patterns are never compressed.
  64.  
  65. Samples are stored in their own files. Their filename extensions are 1,2,3,
  66. etc. There are none zeroes in the extensions. Here comes the example:
  67.  
  68. ALM filename: saysay.alm
  69. sample names: saysay.1, saysay.2, saysay.5, etc.
  70.  
  71. Loader scans directory and loads all the numbers he found. There can be also
  72. only some samples, e.g. 1,2,5,7,10. In this case, loader skips numbers
  73. 3,4,6,8,9.
  74.  
  75. Samples are stored as 8-bit mono UNSIGNED. The frequency for middle C (C-2) is
  76. always standard 8363 Hz (like MOD). Each sapmlefile has this short header:
  77.  
  78. offset length descrioption
  79. ===================================================
  80.    0      1   zero (0) byte - identification byte!!!
  81.    1      2   begin of the loop (Intel word)
  82.    3      2   end of the loop (Intel word)
  83.  
  84. If there is no loop, both values equals to the sample length.
  85. REMEBER! If the first byte isn't zero (0), there are no header!!! That means
  86. you have to test the first byte of the sample, and if there isn't the zero,
  87. it's sample without header. Samples without header cannot have a loop.
  88.  
  89. Some hints:
  90. ~~~~~~~~~~~
  91. Sample volumes cannot be set because of slow CPU speed on that computers. The
  92. volumes can be (and be sure they are) precalculated and whole tune has the same
  93. volume for each sample. This can be done either in ALM editor or in MOD->ALM
  94. converter.
  95.  
  96. The speed info in the offset 7 is in 1/100 of second. That means 12 is the
  97. standard speed - the same speed as 6 in other formats. For speed optimization,
  98. there aren't 100 ticks per second, but only (100/speed) ticks. Beacuse of none
  99. effects in the ALM, one output buffer is not 1/50 sec., but much longer. If the
  100. speed is 12, there are only about 8 ticks per second. This is really uncommon,
  101. but is't very fast, because you don't spend much time updating tune. (It's
  102. designed for that 8bit computer!)
  103.  
  104. Each sample can be up to 32768 bytes long (not 64k!). It's because of Sam
  105. Coupe's segment limitations. You know Sam Coupe is an 8bit computer, so be
  106. happy, that it allows you to use segmented memory addressing. 32k is not good,
  107. but it really couldn't be better. There can be max. 30 samples in one tune, but
  108. the real number is slower, depending of free memory.
  109.  
  110. Channels 1 and 3 are left, channels 2 and 4 are right. Yes, Sam Coupe's sound
  111. chip really has 4 stereo channels. This is the standard LRLR (remember! MOD has
  112. LRRL!!!).
  113.  
  114. If you use PC AT and have 1MB RAM, you'll have no problems with memory and
  115. speed. The ALM player is fast enough to play 44kHz on PC AT 8MHz!!! On the Sam
  116. Coupe, the rate is much lower, about 8kHz.
  117.  
  118. There are lots of MOD tunes converted into ALM. You may need'em if you are
  119. going to add ALM support to your player. So, if it's true, contact the author.
  120.  
  121. -------------------------------------------------------------------------------
  122. This document is provided "as is". But if you have any questions, you can
  123. contact the author. Contact him also if you want to make a new ALM player. :-)
  124.  
  125. Internet e-mail: keprta@risc.upol.cz, keprta@infnw.upol.cz
  126. Snail mail: Aley Keprt, Brezecka 504/30A, Stepanov, 78313, Czech republic
  127. -------------------------------------------------------------------------------
  128. <you can print this doc using 64lines/page>           signed: Aley [eili] Keprt